<template>
  <div class="saas-box">
    <!--渲染的内容-->
    <router-view />
    <!--底部的导航-->
    <NavBottom></NavBottom>
    <div class="updatePrompt" v-if="$store.state.gyzqUpdatePrompt">
      <div class="update-center">
        <img class="u-c-pic" src="./assets/images/gyzq/updatePrompt.png" alt="">
        <div class="u-c-title">观看直播请升级APP</div>
        <div class="u-c-text">请将APP升级至最新版本</div>
        <button class="u-c-btn" @click="closeWebview">我知道了</button>
      </div>
    </div>
    <!-- 全局Popup组件 -->
    <GlobalPopup />
  </div>
</template>
<script>
  import NavBottom from "./pages/NavBottom";
  import fun from "./util/function";
  import req from "./util/req";
  import {
    mapGetters
  } from "vuex";
  import Lockr from "./assets/js/Lockr";
  import Account from "./util/Account";
  export default {
    components: {
      NavBottom,
    },
    created: function() {
      let linkId = fun.getQueryString("linkId")
      if(linkId){
        let argumentData = {
          sessionId: "link-"+linkId, //场次id
          streamType: 12, //视频类型：1-预告 2-直播 3-回看 10-全局统计 11-商品点击 12-页面
          actionValue: 1, //行为：1-进入 2-离开 3-点击播放 4-留言 5-点赞 6-关注 7-分享 8-开播 9-关播 10-最高峰值
          playSource: fun.getPlatform(), //微信 app 游客为web
          url: window.location.href, //当前的url
        };
        req.recordData(argumentData)
      }
      fun.initUserInfo();
      this.getSysOrgInfo();
      this.getOrgShare()
    },
    methods: {
      getOrgShare(){//机构分享
				this.$http.get("/h5live/getOrgShare")
					.then(res => {
						if(res.data.code == "000000" && res.data.data) {
              this.$store.commit('setOrgShareObj',res.data.data)
						}
					})
					.catch(response => {
						console.log(response);
					});
      },
      //获取机构信息以及皮肤
      getSysOrgInfo() {
        this.$http.get("/h5live/getSysOrgInfo?plat=" + fun.getPlatform())
          .then(res => {
            if (res.data.code == "000000") {
              //设置页面title
              if(config.configTitle.hasOwnProperty(window.channel)){//判断配置了这个机构号
              document.title = config.configTitle[window.channel]
              }else{
                document.title = res.data.data.name
              	//document.title = '\u200E';//设置为空
              }
              this.$store.dispatch("SysOrgInfo", res.data.data)
              if(res.data.data.homePageTemplateModel){
                this.$store.dispatch('setSkinStoreObj', res.data.data.homePageTemplateModel); //换肤
              }
            } else {}
          })
          .catch(response => {
            console.log(response);
          });
      },
      //关闭webview 回到app
      closeWebview() {
        openService("", "5", "FN_EMBED_H5_CLOSEVIEW", "");
      }
    },
    watch: {
      '$route'() {
        if (window._czc) {
          let location = window.location
          let contentUrl = location.pathname + location.hash
          let refererUrl = '/'
          window._czc.push(['_trackPageview', contentUrl, refererUrl])
        }
      }
    }
  }
</script>

<style scoped>
  /*@import './assets/css/index.css';*/

  .updatePrompt {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(18, 18, 18, 0.75);
    z-index: 999;
  }

  .updatePrompt .update-center {
    width: 473px;
    padding: 85px 0 70px 0;
    background: #FFFFFF;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .u-c-pic {
    width: 190px;
  }

  .u-c-title {
    font-size: 34px;
    color: #333;
    margin-top: 35px;
  }

  .u-c-text {
    font-size: 26px;
    color: #666;
    margin: 20px 0 42px 0;
  }

  .u-c-btn {
    width: 295px;
    height: 66px;
    background: #F34954;
    font-size: 30px;
    color: #FFF;
    line-height: 66px;
    text-align: center;
    border-radius: 20px;
    border: 0;
    outline: 0;
  }
</style>
